<div id="page-title" class="clearfix">
	<ul class="breadcrumb">
		<li>
			<?php echo CHtml::link('Home',array('/site/index')); ?><span
			class="divider">/</span>
		</li>
		<li>
			<?php echo CHtml::link('Film:'.$film->title.'',array('/film/update','id'=>$film->id)); ?><span
			class="divider">/</span>
		</li>
		<li class="active">Server List</li>
	</ul>
</div>
<!-- /.page-title -->
<?php
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('episode-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button hide')); ?>
<div class="search-form" style="display: none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div>
<!-- search-form -->
<div class="widget">
	<div class="widget-toolbar">
	<?php echo CHtml::link('<i class="icon-step-backward"></i> Back',array('/film/admin'),array('class'=>'btn btn-primary')); ?>
	<?php echo CHtml::link('<i class="icon-film"></i> Add Server',array('/server/create','fid'=>$film->id),array('class'=>'btn btn-primary')); ?>
	</div>
	<!-- /.widget-toolbar -->
</div>

<div class="widget widget-table">
	<div class="widget-header">
		<h3>
			<i class="icon-th-list"></i>
			<?php echo 'Server List (Film:'.$film->title.')'?>		
		</h3>
	</div>
	<!-- /widget-header -->
	<div class="widget-content">
<?php

$form = $this->beginWidget ( 'CActiveForm', array (
		'enableAjaxValidation' => true 
) );
?>
<?php


$this->widget ( 'zii.widgets.grid.CGridView', array (
		'id' => 'server-grid',
	'dataProvider'=>$model->search(),
	'summaryText'=>'',
	'htmlOptions'=>array('class'=>'table table-striped table-bordered responsive'),
	'pagerCssClass'=>'pagination pagination-centered',
	'columns'=>array(
		array(
            'id'=>'autoId',
            'class'=>'CCheckBoxColumn',
            'selectableRows' => '50',   
        ),
        array(
            'name'=>'Name',
            'value'=>'$data->name',
			'htmlOptions'=>array("width"=>"35%"),
        ),
		array(
            'name'=>'Film',
            'value'=>'$data->film[0]["title"]',
			'htmlOptions'=>array("width"=>"32%"),
        ),
		array(
            'name'=>'Order',
            'type'=>'raw',
            'value'=>'CHtml::textField("order[$data->id]",$data->order,array("style"=>"width:50px;"))',
            'htmlOptions'=>array("width"=>"50px"),
        ),
		array(
            'name'=>'active',
            'header'=>'Active',
            'value'=>'($data->active=="1")?("Yes"):("No")'
        ),
		array(
			'header'=>'Action',
			'class'=>'CButtonColumn',
			'buttons'=>array(
        		
		        'delete' => array
		        (
		            'label'=>'Delete',
		        	'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/delete-file-icon_24.png',
		        	'url'=>'Yii::app()->createUrl("server/delete", array("id"=>$data->id))',
		        ),
		        'update' => array
		        (
		            'label'=>'Update',
		        	'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/table-edit-icon_24.png',
		            'url'=>'Yii::app()->createUrl("server/update", array("id"=>$data->id))',
		        ),
		        'view' => array
		        (
		            'label'=>'View Episode',
		        	'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/list-tree-icon.png',
		            'url'=>'Yii::app()->createUrl("episode/admin", array("eid"=>$data->id))',
		        ),
        	),
			'htmlOptions'=>array("width"=>"80px"),
		),
	),
)); ?>
<script>
function reloadGrid(data) {
    $.fn.yiiGridView.update('server-grid');
}
</script>
		<div
			style="padding-top: 10px; border-top: 1px solid #cccccc; padding-left: 20px;">
		<?php echo CHtml::ajaxSubmitButton('Filter',array('server/ajaxupdate'), array(),array("style"=>"display:none;")); ?>
		<?php echo CHtml::ajaxSubmitButton('Activate',array('server/ajaxupdate','act'=>'doActive'), array('success'=>'reloadGrid'),array('class'=>'btn btn-success','style'=>'margin-right:20px;')); ?>
		<?php echo CHtml::ajaxSubmitButton('In Activate',array('server/ajaxupdate','act'=>'doInactive'), array('success'=>'reloadGrid'),array('class'=>'btn btn-warning','style'=>'margin-right:20px;')); ?>
		<?php echo CHtml::ajaxSubmitButton('Delete',array('server/ajaxupdate','act'=>'doDelete'), array('success'=>'reloadGrid'),array('class'=>'btn btn-danger','style'=>'margin-right:20px;')); ?>
		<?php echo CHtml::ajaxSubmitButton('Update sort order',array('server/ajaxupdate','act'=>'doSortOrder'), array('success'=>'reloadGrid'),array('class'=>'btn btn-inverse','style'=>'margin-right:20px;')); ?>
		</div>
		<?php $this->endWidget(); ?>
	</div>
	<!-- /widget-content -->
</div>
<!-- /widget -->
